package com.talkyun.openx.codec;

import com.talkyun.openx.codec.model.PageResult;
import com.talkyun.utils.json.JSON;
import com.talkyun.utils.json.JSONArray;
import junit.framework.TestCase;

import java.util.ArrayList;

public class FastjsonCodecTest2 extends TestCase {

    public void testSimpleArray() {
        String json = JSON.toJsonString(new Object[]{""});
        System.out.println("JSON:" + json);
        JSONArray array = JSON.parseArray(json);
        System.out.println("JSON2:" + array.size());
    }


    public void testPageGenericType() {
        PageResult<PageResult.Item> page = new PageResult<PageResult.Item>();

        ArrayList<PageResult.Item> result = new ArrayList<PageResult.Item>();
        result.add(new PageResult.Item("name", 10));
        result.add(new PageResult.Item("name2", 20));

        page.setResult(result);
        page.setPageSize(15);

        String json = JSON.toJsonString(page);

        System.out.println(json);

        PageResult page2 = JSON.toJavaObject(json, PageResult.class);
        System.out.println(page2);
    }
}